package org.kumas.sgrpc.common.serialize.nativejava;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import org.kumas.sgrpc.common.URL;
import org.kumas.sgrpc.common.serialize.ObjectInput;
import org.kumas.sgrpc.common.serialize.ObjectOutput;
import org.kumas.sgrpc.common.serialize.Serialization;

import static org.kumas.sgrpc.common.serialize.Constants.NATIVE_JAVA_SERIALIZATION_ID;

public class NativeJavaSerialization implements Serialization {


    @Override
    public byte getContentTypeId() {
        return NATIVE_JAVA_SERIALIZATION_ID;
    }

    @Override
    public String getContentType() {
        return "x-application/nativejava";
    }

    @Override
    public ObjectOutput serialize(URL url, OutputStream output) throws IOException {
        return new NativeJavaObjectOutput(output);
    }

    @Override
    public ObjectInput deserialize(URL url, InputStream input) throws IOException {
        return new NativeJavaObjectInput(input);
    }
}